package evs1.restframework.model;

import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import evs1.restframework.anno.Evs11Rest;
import evs1.restframework.anno.Evs11Search;

@Entity 
@Table(name="companies")
@Evs11Rest(plural = "companies")
public class Company {
	@Id @GeneratedValue private Long id;
	@Evs11Search
	private String name;
	@Temporal(TemporalType.TIMESTAMP) private Date founded;
	@Temporal(TemporalType.TIMESTAMP) private Date abandoned;
	@Evs11Search
	private String fieldOfActivity;
	@OneToMany(mappedBy="company", cascade=CascadeType.ALL,fetch = FetchType.EAGER)
	private Set<Skill> skills;
	
	@OneToMany(mappedBy="company", cascade=CascadeType.ALL,fetch = FetchType.EAGER)
	private Set<Occupation> occupations;
	
	public Set<Occupation> getOccupations() {
		return occupations;
	}
	public void setOccupations(Set<Occupation> occupations) {
		this.occupations = occupations;
	}
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Date getFounded() {
		return founded;
	}
	public void setFounded(Date founded) {
		this.founded = founded;
	}
	public Date getAbandoned() {
		return abandoned;
	}
	public void setAbandoned(Date abandoned) {
		this.abandoned = abandoned;
	}
	public String getFieldOfActivity() {
		return fieldOfActivity;
	}
	public void setFieldOfActivity(String fieldOfActivity) {
		this.fieldOfActivity = fieldOfActivity;
	}
	public Set<Skill> getSkills() {
		return skills;
	}
	public void setSkills(Set<Skill> skills) {
		this.skills = skills;
	}
	@Override
	public String toString() {
		return "Company [id=" + id + ", name=" + name + ", founded=" + founded
				+ ", abandoned=" + abandoned + ", fieldOfActivity="
				+ fieldOfActivity + ", skills=" + skills + "]";
	}
}
